package com.lujieni.nio.c2;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

public class WriteClient {

    public static void main(String[] args) throws IOException, InterruptedException {
        SocketChannel sc = SocketChannel.open();
        sc.connect(new InetSocketAddress("localhost", 8081));

        int count = 0;
        while(true){
            ByteBuffer allocate = ByteBuffer.allocate(1024 * 1024);
            int read = sc.read(allocate);
            count = count + read;
            System.out.println(count);

        }


       // Thread.currentThread().join();
    }
}
